package com.silvervine.macnets.consts;

import java.util.HashMap;

/**
 * Created by Rickey on 2018/1/29.
 */

public enum LoginStatus {

    PG_TUNNEL_STA_LOGIN_SUCCESS(0, "登录成功"),

    PG_TUNNEL_STA_LOGIN_CONFIG(4, "加载配置文件失败"),

    PG_TUNNEL_STA_LOGIN_SYSINFO(5, "系统信息参数错误"),

    PG_TUNNEL_STA_LOGIN_RESOLUTION(6, "域名解析失败"),

    PG_TUNNEL_STA_LOGIN_BUILDACCOUNT(7, "生成账号信息失败"),

    PG_TUNNEL_STA_LOGIN_INITNODE(8, "初始化Node失败"),

    PG_TUNNEL_STA_LOGIN_INITFAILED(9, "其他初始化失败"),

    PG_TUNNEL_STA_LOGIN_LOGINFAILED(10, "发送登录请求失败"),

    PG_TUNNEL_STA_LOGIN_LOGOUTED(11, "已经注销（稍后重试登录请求）"),

    PG_TUNNEL_STA_LOGIN_REQUESTING(16, "正在请求登录"),

    PG_TUNNEL_STA_LOGIN_TIMEOUT(17, "登录错误（请求超时）"),

    PG_TUNNEL_STA_LOGIN_NETWORK(18, "登录错误（网络错误）"),

    PG_TUNNEL_STA_LOGIN_BADUSER(19, "登录错误（用户名错误）"),

    PG_TUNNEL_STA_LOGIN_BADPASS(20, "登录错误（密码错误）"),

    PG_TUNNEL_STA_LOGIN_REJECT(21, "登录错误（拒绝访问）"),

    PG_TUNNEL_STA_LOGIN_BUSY(22, "登录错误（服务器正忙）"),

    PG_TUNNEL_STA_LOGIN_FAILED(23, "登录错误（其他登录失败）"),

    PG_TUNNEL_STA_LOGIN_KICKOUT(32, "用户名冲突被服务器踢下线"),

    PG_TUNNEL_STA_LOGIN_UNKNOWN(255, "未知状态"),

    PG_TUNNEL_STA_LOGIN_EXTEND(256, "用户自定义错误码的开始编号"),

    PG_TUNNEL_STA_LOGIN_MAC_ERROR(300, "mac地址不允许登录"),

    PG_TUNNEL_STA_LOGIN_VALIDITYTIME_ERROR(301, "达到使用期限");


    private        int                      mSymbol;
    private        String                   mMessage;
    private static HashMap<Integer, String> contentMap;
    private int code;

    LoginStatus(int symbol, String message) {
        mSymbol = symbol;
        mMessage = message;
    }

    public static String getMessage(int status) {
        if (contentMap == null) {
            contentMap = new HashMap();
            for (LoginStatus loginStatus : LoginStatus.values())
                contentMap.put(loginStatus.mSymbol, loginStatus.mMessage);
        }
        String message = contentMap.get(status);
        return null != message ? message : "未定义异常";
    }

    public int getCode() {
        return mSymbol;
    }

}
